package summary.uesr;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * @Author admin
 * @Date 2019/4/16 14:11
 */
public class UserDaoIO implements UserDao{


    @Override
    public void register(User user) {
        /*
        * */
        Writer out=null;
        BufferedWriter bw=null;
        try {
            out=new FileWriter("user.txt");
            bw=new BufferedWriter(out);
            String s=user.getName()+"-"+user.getPassword()+"-"+user.getEmail();
            bw.write(s);
            bw.newLine();
            bw.flush();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (bw!=null){
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
                if (out!=null){
                    try {
                        out.flush();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
    }

    @Override
    public User login(String name, String password) {
        return null;
    }
}
